home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / clipwr.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  4KB  |  144 lines

  1. /*
  2.  * CLIPWR.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate CLIPWR.rexx without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. /*
  27.  * This will automatically direct the script to the proper
  28.  * software, if it is running.
  29.  */
  30. prtnme = 'IP_Port'; /* assume Image Professional */
  31. if show('P','IP_Port') = 0 then do
  32.   if show('P','IM_Port') = 0 then do
  33.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  34.     say "This script requires IP, IM or IM F/c to run!";
  35.     exit(20);
  36.     end;
  37.   else do
  38.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  39.     end;                 /* We make em, user's break em.          */
  40.   end;
  41.  
  42.   /*
  43.    * This code attempts to read a file called "picmdpath" from REXX:
  44.    * If it can't find it, the script will assume that the commands
  45.    * associated with this PI Module are in "c:". If the file exists,
  46.    * the script will look in the path that is specified in the file.
  47.    * If you create this file, you MUST put a complete, correct path
  48.    * in it; if the commands are in a sub-directory, you have to put
  49.    * the trailing slash on the path (like, device:dir/).
  50.    * 
  51.    */
  52.   cmdpath = 'c:';
  53.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  54.     do
  55.       cmdpath = readln(fhandle);
  56.       call close(fhandle);  /* close the file    */
  57.     end
  58.  
  59. options;
  60. address;
  61.  
  62.   address(prtnme);
  63.   options results;
  64.   'current';
  65.   bufdata = result; /* get name of buffer, if there is one */
  66.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  67.   if bname ~= '<none>' then do
  68.     bufname = bname;
  69.     end;
  70.  
  71.   address(prtnme);
  72.  
  73. 'tofront';
  74.  
  75.   options results;
  76.   'asknumber '||'"Which clipboard unit?" 0'
  77.   unit = result;
  78.   'jackin';
  79.   jackadr = result;
  80.   options;
  81.  
  82.   'wbtofront';
  83.   'lockimage '||bnum;
  84.   address command cmdpath||'CLIPWR '||jackadr||' '||unit;
  85.   'unlockimage '||bnum;
  86.  
  87.   address(prtnme);
  88.   'imtofront';
  89.   address;
  90.  
  91.   exit 0;
  92.  
  93. /*
  94.  * gimmepath
  95.  *
  96.  * This takes the provided argument and sucks the path out of it, then
  97.  * returns that path to the caller, sans file name.
  98.  */
  99. gimmepath:
  100.   arg fullnamegx;
  101.     tempgx = reverse(fullnamegx);
  102.     lengx = length(fullnamegx);   /* get length of string */
  103.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  104.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  105.     seploc = 0; /* assumes current dir, no path supplied */
  106.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  107.       seploc = (lengx - slashdex)+1;
  108.       end;
  109.     else do
  110.       if colondex ~= 0 then do /* we assume we are on a device */
  111.         seploc = (lengx - colondex)+1;
  112.         end;
  113.       end;
  114.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  115.   gxpath = left(fullnamegx,seploc);
  116.   return(gxpath);
  117.  
  118. /*
  119.  * Since this script can't be expected to know where the CD of the user
  120.  * is when this cmd is invoked, we have to check the path the user
  121.  * provides - if it's not specified right from a root, then we have
  122.  * to make it a complete specification from the root.
  123.  */
  124. expandfilename:
  125.   parse arg jfile;
  126.   if index(jfile,':') = 0 then do
  127.     curdir = pragma(D);
  128.     if right(curdir,1) ~= ':' then do
  129.       if right(curdir,1) ~= '/' then do
  130.         if curdir ~= '' then do
  131.           curdir = curdir || '/';
  132.           end;
  133.         end;
  134.       end;
  135.     jfile = curdir||jfile;
  136.     end;
  137.   return(jfile);
  138.  
  139. rvalue:
  140.   wordnum = c2d(readch(fhandle,1)) * 256;
  141.   wordnum = wordnum + c2d(readch(fhandle,1));
  142.   return wordnum;
  143.  
  144.